In [46]:
%matplotlib inline
import json
import urllib2
import matplotlib.pyplot as plt
Use the URL
http://materials-informatics-lab.github.io/2014/09/03/Plotly-Example.html
{"layout":"default","title":"Plot.ly Example","author":"tonyfast","tagline":"An example of Plot.ly embed","tags":["Examples"],"data":{"plotly":{"embed":"https://plot.ly/~TonyFast/4","matlab":"https://plot.ly/~TonyFast/4.m","python":"https://plot.ly/~TonyFast/4.py","json":"https://plot.ly/~TonyFast/4.json"}},"references":["https://plot.ly/api/"],"url":"/2014/09/03/Plotly-Example.html","dir":"/2014/09/03","date":"2014-09-03 00:00:00 -0400","id":"/2014/09/03/Plotly-Example","categories":[]}
In [36]:
# JSON-ified front matter as string
s = '{"layout":"default","title":"Plot.ly Example","author":"tonyfast","tagline":"An example of Plot.ly embed","tags":["Examples"],"data":{"plotly":{"embed":"https://plot.ly/~TonyFast/4","matlab":"https://plot.ly/~TonyFast/4.m","python":"https://plot.ly/~TonyFast/4.py","json":"https://plot.ly/~TonyFast/4.json"}},"references":["https://plot.ly/api/"],"url":"/2014/09/03/Plotly-Example.html","dir":"/2014/09/03","date":"2014-09-03 00:00:00 -0400","id":"/2014/09/03/Plotly-Example","categories":[]}'
In [37]:
d = json.loads(s)
In [38]:
f = urllib2.urlopen(d['data']['plotly']['json'])
In [39]:
data = json.load(f)
In [61]:
for values in data["data"]:
values["x"]
plt.plot(values["x"],values["y"],marker="o")
plt.title("From Plotly")
plt.show()
In [62]:
# Integrated Visualization
from IPython.display import HTML
In [73]:
HTML('<iframe src="'+d["data"]["plotly"]["embed"]+'.embed"'+' width=700 height=500/>')
Out[73]:
In [69]:
Out[69]:
In [ ]: